Clover coverage report - Enterprise Web Services - 1.0
Coverage timestamp: Mon May 30 2005 17:10:32 CEST
file stats: LOC: 146   Methods: 4
NCLOC: 100   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
BuildFileConfigurer.java 65% 89.7% 75% 82.9%
coverage coverage
 1   
 /*
 2   
  * Copyright 2001-2004 The Apache Software Foundation.
 3   
  * 
 4   
  * Licensed under the Apache License, Version 2.0 (the "License");
 5   
  * you may not use this file except in compliance with the License.
 6   
  * You may obtain a copy of the License at
 7   
  * 
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  * 
 10   
  * Unless required by applicable law or agreed to in writing, software
 11   
  * distributed under the License is distributed on an "AS IS" BASIS,
 12   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  * See the License for the specific language governing permissions and
 14   
  * limitations under the License.
 15   
  */
 16   
 
 17   
 package org.apache.geronimo.ews.ws4j2ee.toWs.misc;
 18   
 
 19   
 import java.io.File;
 20   
 import java.io.FileWriter;
 21   
 import java.io.IOException;
 22   
 import java.io.PrintWriter;
 23   
 import java.util.ArrayList;
 24   
 import java.util.StringTokenizer;
 25   
 
 26   
 import org.apache.commons.logging.Log;
 27   
 import org.apache.commons.logging.LogFactory;
 28   
 import org.apache.geronimo.ews.ws4j2ee.context.InputOutputFile;
 29   
 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
 30   
 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
 31   
 import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
 32   
 import org.apache.geronimo.ews.ws4j2ee.toWs.dd.JaxrpcMapperGenerator;
 33   
 import org.apache.geronimo.ews.ws4j2ee.utils.FileUtils;
 34   
 
 35   
 /**
 36   
  * @author Srinath Perera(hemapani@opensource.lk)
 37   
  */
 38   
 public class BuildFileConfigurer implements Generator {
 39   
     private J2EEWebServiceContext j2eewscontext;
 40   
 
 41   
     protected static Log log =
 42   
             LogFactory.getLog(JaxrpcMapperGenerator.class.getName());
 43   
 
 44  11
     public BuildFileConfigurer(J2EEWebServiceContext j2eewscontext) throws GenerationFault {
 45  11
         this.j2eewscontext = j2eewscontext;
 46   
     }
 47   
 
 48  11
     public void generate() throws GenerationFault {
 49  11
         try {
 50  11
             FileUtils.copyFile(new File("conf/common.xml"),new File(j2eewscontext.getMiscInfo().getOutPutPath() + "/common.xml"));
 51   
 
 52  11
             String buildfile = j2eewscontext.getMiscInfo().getOutPutPath() + "/build.xml";
 53  11
             if (j2eewscontext.getMiscInfo().isVerbose())
 54  0
                 log.info("genarating " + buildfile + ".................");
 55  11
             PrintWriter out = new PrintWriter(new FileWriter(buildfile));
 56   
             
 57   
             
 58  11
             out.write("<?xml version=\"1.0\"?>\n");
 59  11
             out.write("<!DOCTYPE project [\n");
 60  11
             out.write("        <!ENTITY properties SYSTEM \"file:common.xml\">\n");
 61  11
             out.write("]>\n");
 62  11
             out.write("<project basedir=\".\" default=\"dist\">\n");
 63   
             
 64  11
             out.write("\t&properties;\n");
 65   
             
 66  11
             writeproperty("mapping.file",j2eewscontext.getMiscInfo().getJaxrpcfile(), out);
 67  11
             writeproperty("wsdl.file",j2eewscontext.getMiscInfo().getWsdlFile(), out);
 68  11
             writeproperty("webservice.file",j2eewscontext.getMiscInfo().getWsconffile(), out);
 69   
 
 70  11
             out.write("    <path id=\"local.classpath\" >\n");
 71  11
             File file = new File(".");
 72  11
             File tempfile = new File(file,"target/classes");
 73  11
             if(tempfile.exists()){
 74  11
                 out.write("     <pathelement location=\""+tempfile.getCanonicalPath()+"\"/>\n");
 75   
             }
 76   
             
 77  11
             tempfile = new File(file,"target/test-classes");
 78  11
             if(tempfile.exists()){
 79  11
                 out.write("     <pathelement location=\""+tempfile.getCanonicalPath()+"\"/>\n");
 80   
             }
 81   
 
 82  11
             ArrayList classpathelements = j2eewscontext.getMiscInfo().getClasspathElements();
 83  11
             if (classpathelements != null) {
 84  11
                 for (int i = 0; i < classpathelements.size(); i++) {
 85  11
                     File pathFile = (File) classpathelements.get(i);
 86  11
                     System.out.println(pathFile.getName());
 87  11
                     out.write("        <pathelement location=\""
 88   
                             + pathFile.getCanonicalPath() + "\"/>\n");
 89   
                 }
 90   
             }
 91  11
             out.write("    </path>\n");
 92   
 
 93   
 
 94   
 
 95   
 
 96  11
             out.write("\t<target name=\"copy-j2ee-resources\">\n");
 97   
                
 98   
 
 99   
 
 100  11
             for (int i = 0; i < classpathelements.size(); i++) {
 101  11
                 File pathelement = (File) classpathelements.get(i);
 102  11
                 if(pathelement.isFile() ){
 103  6
                     out.write("    <unzip src=\""+pathelement.getCanonicalPath()+"\" dest=\"${build.classes}\"></unzip>\n");
 104   
                 }else{
 105  5
                     out.write("    <copy todir=\"${build.classes}\">\n");
 106  5
                     out.write("       <fileset dir=\""+pathelement.getCanonicalPath()+"\">\n");
 107  5
                     out.write("           <include name=\"**/*.class\"/>\n");
 108  5
                     out.write("           <include name=\"**/*.xml\"/>\n");
 109  5
                     out.write("           <include name=\"**/*.wsdl\"/>\n");                    
 110  5
                     out.write("       </fileset>\n");
 111  5
                     out.write("    </copy>\n");
 112   
                 }
 113   
                 
 114   
             }
 115  11
             out.write("\t</target>\n");
 116   
             
 117   
                         
 118  11
             out.write("</project>\n");
 119  11
             out.close();
 120   
         } catch (IOException e) {
 121  0
             log.error(e);
 122  0
             throw GenerationFault.createGenerationFault(e);
 123   
         }
 124   
     }
 125   
 
 126  0
     private StringTokenizer getClasspathComponets() {
 127  0
         String classpath = System.getProperty("java.class.path");
 128  0
         String spearator = System.getProperties().getProperty("path.separator");
 129  0
         return new StringTokenizer(classpath, spearator);
 130   
     }
 131   
 
 132  33
     private void writeproperty(String property, InputOutputFile file, PrintWriter out) throws GenerationFault {
 133  33
         try {
 134  33
             if (file != null) {
 135  33
                 String fileName = file.fileName();
 136  22
                 if (fileName != null) {
 137  22
                     File absFile = new File(fileName);
 138  22
                     if (absFile.exists())
 139  22
                         out.write("<property  name=\""+property+"\" value=\""+absFile.getCanonicalPath()+"\"/>\n");
 140   
                 }
 141   
             }
 142   
         } catch (Exception e) {
 143   
         }
 144   
     }
 145   
 }
 146